import json

from celery_tasks.main import celery_app
from utils.RlySMSCode.Rly import CCP


# name：异步任务别名
@celery_app.task(name='send_sms_code')
def send_sms_code(mobile, sms_code):
    """
    发送短信异步任务
    :param mobile: 手机号
    :param sms_code: 短信验证码
    """
    try:
        send_ret = CCP().send_sms_code(mobile, sms_code)
        send_ret = json.loads(send_ret)
        if send_ret.get("statusCode") == "000000":
            # 发送成功
            return 0
        else:
            # 发送失败
            return -1
    except Exception as e:
        print(e)
